Repository navigation
Bound native Markdown Inbox reader output - #9195
huangruiteng wants to merge 1 commit into
Conversation
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google DeepMind · self_reported
动机 / Motivation
在原生 Codex 会话中调用 manager-inbox read --format markdown 读取含多条请求或长文描述的收件箱时,模型和执行器会遇到工具输出截断问题。在改动前的基线 f0018b1b19 上,Markdown 收件箱默认沿用 12,000 字节上限(如 6.5 KB 中英文页会直接以 8,134 字节内联返回,18 KB 页则会生成 12,000 字节分片),原生 shell 工具在模型历史中截断输出并导致恢复页偏移量与正文长度不匹配;改动后,Markdown 响应开场、私有捕获页与直连恢复命令统一封顶在 5,000 字节,同时引导在继续截断时调小双参数。
所有超过 5,000 字节的 Markdown 收件箱结果都会退避为不超过 5,000 字节的摘要绑定 reader,按 5,000 字节分页并经 SHA-256 与 UTF-8 字节偏移校验无损还原原文和游标;JSON 视图与 quota 首读 12,000 字节预算保持不变。本 PR 不修改 manager-inbox read --format json 输出限制、不改动 quota 首读 12,000 字节常数、不新增 CLI 参数或持久化状态,也不在本地工作树外测试正式 Desktop 安装版与飞书实机。
改动思路 / Approach
如果不区分原生 shell 工具历史保留窗与普通 JSON/quota 捕获通道而直接将 NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES 全局降到 5,000 字节,会无故把 quota should-run 首读命令的分页数扩大一倍以上;反之若维持 12,000 字节并在提示中仅泛泛建议“smaller page”,调用方在受限 shell 环境下仍会先遇到一次截断再手动试探参数。因此本方案:在既有的原生传输配置模块 native_context_profile.py 新增专用的 5,000 字节常量 NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES,并仅由 _read_markdown 在构造开场与续读命令时复用,而不改动共享的 NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES(12,000 字节)或捕获存储协议。当前 PR 边界仅限定在 Markdown 收件箱渲染入口(manager_inbox.py)、传输上限定义(native_context_profile.py)、能力文档说明及对应契约测试,不扩张到共享 quota 首读器或 JSON 入口。
- 复用与边界清晰:不变量(摘要与偏移一致、不重复写读取回执)仍由既有的
context_capture_read_command与decision_capture单点负责;manager_inbox.py仅作为渲染与传输上限消费者引用新常数;--format json出口完全不受影响,保留原始完整结构输出。
具体改动 / Changes
- 规范基线与逐条映射:对照变更前的
loopx/capabilities/manager_context/README.md(不可变基线spec_revision:f0018b1b19c884a8fbe6b1f88a75c479ae296c71)对原生收件箱读取契约的逐条判定:MC-full-delivery(implemented):继续完整保留请求原文、状态、读回执、警告与分页游标(tests/test_delegation_turn_context.py28 passed 及 6.5 KB 中文多字节对照验证无损重装)。MC-digest-bounded-reader(implemented):超限 Markdown 页继续退避为绑定 SHA-256 与 UTF-8 字节偏移的私有 reader,读回保存捕获时不重复写 Inbox 回执(manager_inbox.py:111-169)。MC-json-parity(implemented):普通/JSON CLI 路径维持原状,不被 5,000 字节限制截断或转为捕获器(实测同一 4 条中文收件箱 JSON 输出 36,597 字节完整返回,Markdown 输出 2,013 字节开场)。- 文档同步审阅说明:本 PR 同步将
loopx/capabilities/manager_context/README.md中英文段落描述的 12,000 字节预算更新为 5,000 字节序列化输出上限(含读取命令和导航),与实现边界及docs/reference/required-work-context.md中的quota12,000 字节职责分离保持一致。
关键代码讲解
NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES(loopx/control_plane/turn_driver/native_context_profile.py:13-15):新增独立常数5000,同时保留NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES = 12000供quota_capture.py与quota_native_context.py继续使用,避免波及非 Markdown 收件箱路径。_read_markdown(loopx/cli_commands/manager_inbox.py:111-169):将limit由NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES切换为NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES,使内联门限、短引用short_command(page_bytes=5000, max_page_output_bytes=5000)、直连direct_command及开场尺寸校验一致受 5,000 字节约束;同时将第 145-146 行恢复指引从泛称“smaller page”细化为同时指定--page-bytes与--max-page-output-bytes。test_unbound_cli_first_read_leaves_inbox_rows_to_its_required_read(tests/test_delegation_turn_context.py:216-347):将 5 处输出断言上限由12_000收紧到5_000,覆盖开场、分页、引用丢失报错(<= 5000)及超限失败分支。
本 PR 共改动 4 个文件(+19 / -12 行):生产代码 2 个文件 +7 / -3 行,测试 1 个文件 +6 / -5 行,双语文档 1 个文件 +6 / -4 行;无新增模块、协议字段或状态流转。
对主干的风险 / Risks
- 活跃调用路径与无退化边界:
manager_inbox.py:555-558仅在manager_inbox_action == "read"且format == "markdown"时调用_read_markdown;经实测同一 4 条中文收件箱下--format markdown输出2,013B摘要开场而--format json仍完整输出36,597B原始数组,确认无非 Markdown 路径溢出。 - 中文多字节与降级路径反例验证:在
a789e210c3独立运行 6.5 KB 中文多字节边界样本(介于 5,000 与 12,000 字节之间)时,基线f0018b1b19直接内联返回8,134B(未分页),而候选输出2,012Bshort_opening并拆分为 3 页(每页<= 5,000B)无损重建原始 JSON 与next_cursor;当private_capture_supported()为False退回direct_opening时仅1,571B <= 5,000B;按新提示将--page-bytes 2000 --max-page-output-bytes 2000调小后输出精确限制在2,000B内。 - 文本义务对齐:
manager_inbox.py:145-146与README.md:371-388的提示更新仅把预算数值与两个分页参数显式化,未削弱摘要校验、EOF 读取与“不代表收件箱为空/不自动消费回执”等安全条款。 - 本机验证结果:
tests/test_delegation_turn_context.py:28 passed, 2 skipped(PowerShell 用例在 macOS 跳过)(PASS)。- 周边收件箱与分页/回执测试(
test_inbox_pagination.py、test_inbox_receipt_recovery.py、test_inbox_read_recovery.py、test_manager_context_roundtrip.py):177 passed(PASS)。 ruff checkPASS;mypy(17 个内核源文件)0 errors(PASS);canary premerge --tier quick4/4 检查组通过且公开边界loopx checkPASS。- 远端托管 CI 未查询(
wait_for_ci=false),正式 Desktop 安装包与真实飞书通道未在本次审查实测。
我的整体评价 / Verdict
本 PR 对 long_horizon 与 user_experience 均判定为 improved:将 Markdown 收件箱及其引导命令严格收敛到 5,000 字节内避免模型侧 shell 工具静默截断,同时在提示中直接给出可执行的双参数恢复指令,且不伤及 JSON 与 quota 首读路径。visual_review 为 not_applicable(已检查 manager_inbox.py、native_context_profile.py 与 manager_context/README.md,无任何前端或 Lark UI 呈现改动,unverified_scope 为 none)。
前后对比与反例探针确认:基线在 5–12 KB 区间内联输出超标且 12 KB 续页过宽,候选严格守住 5,000 字节上限并在中英文多字节分页、直连回退与双参数调小下完全一致;代码净改动仅 +19/-12,未新增冗余副本、未变更公共词汇或权限契约;合并基线仅落后无需冲突的文档与工作台提交。精确 head a789e210c3fb68a69418e31f9fb8b6b33fd9a926 已核对未变,无阻塞性发现。
English verdict: APPROVE — Exact-head review on a789e21 passes with zero blocking findings. Capping Markdown Inbox responses and capture paging at NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES (5000) keeps openings, fallback direct commands, and CJK multi-byte pages within 5,000 bytes while preserving JSON format and quota 12,000-byte parity (28+177 Python tests, base-vs-head CJK/JSON counterfactuals, ruff, kernel mypy, and quick premerge all PASS).
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
托管 Agent 需要在开始工作前读全 Inbox。原生 shell 容量较小时,成功退出的命令仍可能只交付一部分字节。 当前 main 的 #9095 区分 Markdown 开场的限制与已经声明的大页 reader 配置。 用主干现有的明确 64,000 字节配置,在真实 File 和 SQLite 上读取同一批 23 条请求。两种后端都从主干的 5 次 capture reader 调用增加到本头的 59 次,逻辑页仍为 2 页,全文和原游标均读回。普通 reader 和直连恢复命令都忽略了原显式预算。 提案将 Markdown 开场、直连恢复和引用续读统一限制在 5,000 字节,并明确两项恢复参数。 本轮核验真实本地 CLI、File 和 SQLite。没有复跑托管 CI 或正式安装版 Desktop 的原生输出限制。
改动思路 / Approach
沿现有 Markdown 展示边界限制开场,续读继续使用同一个不可变 capture 和精确字节偏移。 已记录的 Inbox 读取和回执保存在当前作用域,页长由输出现实决定。 沿用主干的显式 native reader 配置,默认以较小预算保护未知容量 shell,避免给 quota 和 JSON 路径引入新的全局限制。
具体改动 / Changes
逐项检查当前头 a789e21 和 merge base 7dfdd7a,4 个文件,+19/-12。当前主干 a6ffb3b 与提案在 Markdown Inbox 预算选择和原生验收测试发生内容冲突。当前主干规范明确了已声明容量的兼容路径。 评审依据为 a6ffb3b。 目标规范
bounded-markdown· Keep unknown-capacity native Markdown openings and reader outputs within the intended conservative bound.complete-capture· Preserve all original requests, digest, offsets and cursor after bounded reads.declared-reader-profile· Preserve the existing declared capture-reader output profile for qualified hosts.
关键代码讲解
- Markdown 开场 计算含结尾换行的 UTF-8 字节数,再决定是否提供捕获引用。
- 原来源恢复 生成直接和短引用命令,两路均使用单一 5,000 字节限制。
- 共享原生配置 保留 quota 配置,增加 Inbox 专用常数。
- 主干正反验收 覆盖两种后端、声明大页、摘要恢复和逐页进度。
对主干的风险 / Risks
[P2] 收紧未知容量时保留已声明的大页 Inbox 读取能力。 在 #9095 的预算 owner 上收紧未知容量时的 Markdown 开场和续读。对已明确声明且能保留较大输出的调用保留原 reader 路径。如需收缩已声明容量的行为,应更新相应契约,并以同一负载明确权衡补读成本。 这些新增调用都发生在业务工作之前。默认压缩的收益已经能独立验收,配置大页的宿主仍需有可用预算。
在 5,000 字节路径,两个后端均完整读回 23 条多字节请求,且所有 capture reader 的最大序列化输出为 5,000 字节。摘要、原不可变文件与 byte offset 验证均通过。相对实际分叉点,本地 quick premerge 通过。 同一强制断言在当前 main 的 File/SQLite × 12,000/64,000 矩阵通过。旧分叉点没有主干新增的显式覆盖接口,提案准确头也未继承它。 两种后端的本地输出与分片数已测量,实际宿主的保留效果和长期总成本未从这些数字推断。
我的整体评价 / Verdict
请求修改。沿现有 Markdown 展示边界限制开场,续读继续使用同一个不可变 capture 和精确字节偏移。 已记录的 Inbox 读取和回执保存在当前作用域,页长由输出现实决定。 5,000 字节路径正确交付全文。当前主干的显式大页路径尚未与该修改完成集成。 请复验小窗保底与已声明大窗两支,记录两个路径的最大全量输出和读取调用数。
English verdict: REQUEST_CHANGES at a789e21. The 5 KB path preserves multibyte content and capture recovery. Current main respects an explicitly declared 64 KB reader profile. For the same 23 requests on File and SQLite, this head increases reader calls from 5 to 59 on each. Preserve the explicitly qualified reader path when integrating the narrower fallback.
| "page's content length against its offsets, and complete coverage through total_bytes. " | ||
| "If output is missing or truncated, reread that range of the same capture with a smaller page. " | ||
| "If output is missing or truncated, reread that range of the same capture with smaller " | ||
| "--page-bytes and --max-page-output-bytes. " |
There was a problem hiding this comment.
[P2] 收紧未知容量时保留已声明的大页 Inbox 读取能力。用主干现有的明确 64,000 字节配置,在真实 File 和 SQLite 上读取同一批 23 条请求。两种后端都从主干的 5 次 capture reader 调用增加到本头的 59 次,逻辑页仍为 2 页,全文和原游标均读回。普通 reader 和直连恢复命令都忽略了原显式预算。 在 #9095 的预算 owner 上收紧未知容量时的 Markdown 开场和续读。对已明确声明且能保留较大输出的调用保留原 reader 路径。如需收缩已声明容量的行为,应更新相应契约,并以同一负载明确权衡补读成本。
Problem
Native Codex's shell tool clipped a 12,000-byte Markdown Inbox response even though the command exited successfully. The page could still parse as JSON, but the recovered text was shorter than its declared UTF-8 offset. The caller had to reread the saved page with smaller limits.
Change
Cap the serialized Markdown Inbox response, capture opening, and generated continuation at 5,000 bytes. The same digest-bound reader preserves the complete request text, receipts, and cursors. Recovery guidance now names both flags to lower if a host has a smaller output budget. The JSON command and shared quota reader keep their existing limits.
The implementation reuses the existing native transport profile and private capture path. There is no new CLI option, state transition, or authority check.
Validation
0.171.0-alpha.13, the same synthetic File workload triggered three byte-gap recoveries on base7dfdd7a. The candidate used the generated commands with no page-size overrides or clipped pages on File or SQLite. Each candidate run verified the UTF-8 offsets and SHA-256, read all 24 original briefs across a new arrival, and rejected a cursor for a different Agent without writing read receipts.f0018b1, with the exact-scope change-quality receipt verified.Related evidence for the original exact-head Inbox work. #9169
Integration with the delegation reader
26e7110from Git tree80a377b. The native Codex app-server ran two guarded Inbox turns for each isolated File and SQLite store via the stdio Effect runtime. A loopback inference fixture drove the commands. Original delegation reader #9169